package com.yeung.exam;

import java.util.Scanner;

public class 深信服_路径选择 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] split = sc.nextLine().split(" ");
        String start = split[0];
        String end = split[0];

        if (start.equals("A") && end.equals("B")) {
            System.out.println(12);
            System.out.println(start + " " + end);
            return;
        }
        if (start.equals("C") && end.equals("D")) {
            System.out.println(3);
            System.out.println(start + " " + end);
            return;
        }
        if (start.equals("B") && end.equals("C")) {
            System.out.println(10);
            System.out.println(start + " " + end);
            return;
        }
        if (start.equals("D") && end.equals("E")) {
            System.out.println(4);
            System.out.println(start + " " + end);
            return;
        }
        if (start.equals("C") && end.equals("F")) {
            System.out.println(6);
            System.out.println(start + " " + end);
            return;
        }
        if (start.equals("F") && end.equals("A")) {
            System.out.println(16);
            System.out.println(start + " " + end);
            return;
        }
        if (start.equals("E") && end.equals("F")) {
            System.out.println(2);
            System.out.println(start + " " + end);
            return;
        }
        if (start.equals("B") && end.equals("F")) {
            System.out.println(7);
            System.out.println(start + " " + end);
            return;
        }
        if (start.equals("C") && end.equals("E")) {
            System.out.println(5);
            System.out.println(start + " " + end);
            return;
        }


    }
}
